<?php
	
   

   function MakeXMLResponse($xmlResp, $strWhat) 
   {
	   printf("<XMLRESPONSE Topic=\"%s\">\n", $strWhat) ;
	   foreach($xmlResp as $strText)
	   {		
         print($strText. "\n") ;	
	   }
	   printf("</XMLRESPONSE>") ;	
   }
  
   

  
  
/***********************************************************************************
   
    
 
************************************************************************************/  
/*
   foreach ($HTTP_GET_VARS as $var => $value) {
    echo "$var = $value<br>\n";
    }
*/
   $myResult = array() ;
 

   if( isset($_GET['TOPIC']) && ( 0 == strcasecmp($_GET['TOPIC'], 'test')) )
   {
   	$xmlResponse = array() ;
	   $strXML = sprintf( "<APPOINTMENT ID=\"%s\">\n", "1")  ; //Datasources always have subnodes
	   array_push( $xmlResponse, $strXML );
	   $strXML = sprintf("<DATUM>%s</DATUM>\n", "07.12.2007") ;
	   array_push( $xmlResponse, $strXML );   
      MakeXMLResponse($xmlResponse, '2112PortalPersister') ;
   }


   if( isset($_GET['TOPIC']) && ( 0 == strcasecmp($_GET['TOPIC'], 'store')) )
   {
   	$strFilename = "portalSettings.xml.txt";

      $strMsg = "You will upload to $strFilename" ;
	      $fp = fopen ($strFilename, "wb");


      if(!$fp)
        $strMsg =  "Cannot open" ;
      else
        echo "open OK\n" ;
        //$strTmp = html_specialchars($_POST['XML_Message'];
       fwrite($fp, $strMsg, strlen( $strMsg)) ;
      fclose($fp) ;
   }


   /*The Property Loader*/
   if( isset($_GET['TOPIC']) && ( 0 == strcasecmp($_GET['TOPIC'], 'load')) )
   {
      $strFilename = "portalSettings.xml.txt";
   	if (!($fp = fopen($strFilename, "rb"))) 
	   {
		   die("ProcessXML: could not open XML input ");
	   }
	   while ($data = fread($fp, 4096)) 
	   {
	      //$data = stripslashes ( $data );
		   echo $data. "\n" ;		   
	   }
      fclose($fp) ;
   }  

?>
